#!/bin/bash -x

# read config
. ../../steps.config

CWS=`echo $* | grep '\--branch' | sed -e 's/.*--branch\=//' -e 's/ .*//' | grep -v "[A-Z][A-Z][A-Z][0-9][0-9][0-9]_m[0-9]*"`

if [ "$CWS" ] ; then
  if [ -z $autoconfBinary ]
  then
    autoconfBinary=autoconf
  fi

  $autoconfBinary || exit 22
fi

echo $configureswitches

#this is a hack for cygwin inability to use the normal procedure due to quoting problems
  grep configureswitches < ../../steps.config |sed 's/[^"]*"//'|sed 's/"$//'|sed 's/.*/.\/configure & || exit \$?/' > configure_line_tmp
  set -x
  source configure_line_tmp
  set +x
#original which should get restored someday starts here
  #./configure $configureswitches || exit $?
#done

# put name of OOo config file created by configure in $envname
. ../../getOOoEnv

echo setting up CWS information

if [ "$CWS" ] ; then
  echo CWS_WORK_STAMP=$CWS >> $envname
  echo CWS_WORK_STAMP_EXT=_$CWS >> $envname
  echo export CWS_WORK_STAMP CWS_WORK_STAMP_EXT >> $envname
fi

LANG=`echo $* | grep '\--languages' | sed -e 's/.*--languages\=\"//' -e 's/\".*//'`
echo WITH_LANG=\"\$WITH_LANG\ $LANG\" >> $envname
echo export WITH_LANG >> $envname

if [ $envname == "winenv.set.sh" -o $envname == "winmingw.set.sh" ]
then
  echo 'WINDOWS_VISTA_PSDK=TRUE' >> $envname
  echo export WINDOWS_VISTA_PSDK >> $envname

  echo 'DISABLE_ATL=TRUE' >> $envname
  echo export DISABLE_ATL >> $envname

  echo 'DISABLE_ACTIVEX=TRUE' >> $envname
  echo export DISABLE_ACTIVEX >> $envname
fi

echo done

